package router

import (
	"fanqiechaodan-blog/api"
	"fanqiechaodan-blog/views"
	"net/http"
)

func Router() {
	// 首页
	http.HandleFunc("/", views.HTML.Index)
	// 根据分类获取文章列表
	http.HandleFunc("/category/", views.HTML.Category)
	// 文章详情
	http.HandleFunc("/post/", views.HTML.Detail)
	// 登录页面
	http.HandleFunc("/login", views.HTML.Login)
	// 写文档页面
	http.HandleFunc("/writing", views.HTML.Writing)
	// 归档
	http.HandleFunc("/pigeonhole", views.HTML.Pigeonhole)
	// 登录
	http.HandleFunc("/api/v1/login", api.API.Login)
	// 获取七牛token
	http.HandleFunc("/api/v1/qiniu/token", api.API.QiniuToken)
	// 查询文章
	http.HandleFunc("/api/v1/post/search", api.API.SearchPost)
	// 根据文章获取详情
	http.HandleFunc("/api/v1/post/", api.API.GetPost)
	// 发布文章
	http.HandleFunc("/api/v1/post", api.API.SaveAndUpdatePost)
	// 删除文章
	http.HandleFunc("/api/delete/v1/post/", api.API.DeletePost)
	http.Handle("/resource/", http.StripPrefix("/resource/", http.FileServer(http.Dir("public/resource/"))))
}
